package com.example.service.impl;

import com.example.dao.VoteDao;
import com.example.entity.Vote;
import com.example.entity.VoteMeg;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.UUID;

/**
 * @author 陈俊杰
 */
@Service
public class VoteService {

    @Autowired
    private VoteDao voteDao;

    /**
     * 添加投票信息
     * @param vote
     * @param voteList
     * @return
     */
    public String addVote(VoteMeg vote, List<Vote> voteList){
        vote.setId(UUID.randomUUID().toString());
        vote.setStatus("进行中");
        return voteDao.addVote(vote,voteList);
    }

    /**
     * 获取所有投票信息
     * @return
     */
    public List<VoteMeg> getAllVote(){
        return voteDao.getAllVote();
    }

    /**
     * 获取一次投票记录
     * @param id
     * @return
     */
    public List<Vote> getOneVote(String id){
        return voteDao.getOneVote(id);
    }

    public void offVote(String id){
        voteDao.offVote(id);
    }
}
